//
//  SEGRequestManager.m
//  ExcellentHome
//
//  Created by 梁昆 on 16/8/30.
//  Copyright © 2016年 陈区. All rights reserved.
//

#import "SEGRequestManager.h"
#import <Commom/SEGEncryptRule.h>

@implementation SEGRequestManager

#pragma mark - 获取密码配置信息
- (void)requestPasswordConfigInfo:(SEGNetworkReponse)finished {
    NSString *urlString = [SEGServerManager serverUrlJoint:kBrowerRootURL,@"/uhomecp-ocm/rest-api/ocm/commonConfig/getCommonConfig",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:nil finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        // 处理文案
        NSString *passwordRule = @"密码必须8-20位，并且包含大小写英文字母、数字";
        NSMutableString *newPasswordRule = [NSMutableString string];
        if (isSuccessed && [result isKindOfClass:[NSDictionary class]] && [result[@"data"] isKindOfClass:[NSDictionary class]]) {
            //"pwdIncludeSpecialChar":"mock",       密码包含特殊字符 0不包含 1-包含
            //"pwdIncludeDigital":"mock",          密码包含数字 0不包含 1-包含
            //"pwdIncludeLower":"mock",            密码包含小写字符 0不包含 1-包含
            //"pwdIncludeUpper":"mock"             密码包含大写字符 0不包含 1-包含
            BOOL pwdIncludeSpecialChar = [result[@"data"][@"pwdIncludeSpecialChar"] boolValue];
            BOOL pwdIncludeDigital = [result[@"data"][@"pwdIncludeDigital"] boolValue];
            BOOL pwdIncludeLower = [result[@"data"][@"pwdIncludeLower"] boolValue];
            BOOL pwdIncludeUpper = [result[@"data"][@"pwdIncludeUpper"] boolValue];
            if (pwdIncludeLower && pwdIncludeUpper) {
                [newPasswordRule appendString:@"大小写英文字母"];
            } else if (pwdIncludeUpper && !pwdIncludeLower){
                [newPasswordRule appendString:@"大写英文字母"];
            } else if (!pwdIncludeUpper && pwdIncludeLower){
               [newPasswordRule appendString:@"小写英文字母"];
            }
            if (pwdIncludeDigital) {
                if (newPasswordRule.length > 0) {
                    [newPasswordRule appendString:@"、"];
                }
                [newPasswordRule appendString:@"数字"];
            }
            if (pwdIncludeSpecialChar) {
                if (newPasswordRule.length > 0) {
                    [newPasswordRule appendString:@"、"];
                }
                [newPasswordRule appendString:@"特殊字符"];
            }
        }
        if (newPasswordRule.length > 0) {
            [newPasswordRule insertString:@"密码必须8-20位，并且包含" atIndex:0];
            passwordRule = [newPasswordRule copy];
        }
        
        finished(isSuccessed, passwordRule, codeType, errorMessage);
    }];
}

#pragma mark - 注销账号界面，获取短信验证码
/// 注销界面 获取短信验证码
- (void)logout_requestGetCaptchasByTel:(NSString *)tel
                               imgCode:(NSString *)imgCode
                           randomToken:(NSString *)randomToken
                              Finished:(SEGNetworkReponse)finished {
    NSDictionary* pramas = @{
                             @"tel" : kAccountMobile,
                             @"imgCode" : imgCode,
                             @"randomToken" : randomToken,
                             @"appType": @"APP_C",
                             @"businessCode" : @"register",
                             @"accountCode" : kAppPlatformCode
                             };
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/uhomecp-sso/v1/sms/sendSms",nil];
    [SEGHTTPBusinessManager seg_requestJSONWithMethod:POST URLString:urlString parameters:pramas finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        finished(isSuccessed,result, codeType, errorMessage);
    }];
}

#pragma mark - 忘记密码界面，获取验证码
//忘记密码获取验证码
- (void)requestGetCaptchasByTel:(NSString*)tel
                        imgCode:(NSString*)imgCode
                    randomToken:(NSString*)randomToken
                       Finished:(SEGNetworkReponse)finished
{
    
    NSDictionary* pramas = @{
                             @"tel" : tel,
                             @"imgCode" : imgCode,
                             @"randomToken" : randomToken
                             };
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/uhomecp-sso/v1/userApp/getVerCodeForReset",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:pramas finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        finished(isSuccessed,result, codeType, errorMessage);
    }];
}

#pragma mark - 获取验证码
/// 获取安全改造的验证码
- (void)requestSecurityRefreshCheckCodeWithFinished:(SEGNetworkReponse)finished {
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/authc-restapi/v1/auth/code/getImgCode",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:nil finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        if (!isSuccessed) {
            finished(NO, result, codeType, errorMessage);
            return;
        }
        
        if ([result valueForKey:@"data"] && [[result valueForKey:@"data"] isKindOfClass:[NSDictionary class]]) {
            self.seg_segtelcaptchasbyregistermodel = [SEGTelCaptchasByRegisterModel yy_modelWithJSON:[result valueForKey:@"data"]];
        }
        finished(isSuccessed, result, codeType, errorMessage);
    }];
}

-(void)requestRefreshCheckCodeFinished:(SEGNetworkReponse)finished{
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/uhomecp-sso/v1/userApp/refresh",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:nil finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        if (!isSuccessed) {
            finished(NO,result, codeType, errorMessage);
            return;
        }
        
        if ([result valueForKey:@"data"] && [[result valueForKey:@"data"] isKindOfClass:[NSDictionary class]]) {
            self.seg_segtelcaptchasbyregistermodel = [SEGTelCaptchasByRegisterModel yy_modelWithJSON:[result valueForKey:@"data"]];
        }
        finished(isSuccessed,result, codeType, errorMessage);
    }];
}

#pragma mark - 注册界面，获取验证码

//注册获取手机验证码 网络请求
- (void)requestVerCodeForRegisterByRegister:(NSString*)tel
                                    imgCode:(NSString*)imgCode
                                randomToken:(NSString*)randomToken
                                   Finished:(SEGNetworkReponse)finished
{
    
    NSDictionary* params = @{
                             @"tel" : tel,
                             @"imgCode" : imgCode,
                             @"randomToken" : randomToken
                             };
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/uhomecp-sso/v1/userApp/getVerCodeForRegister",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:params finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        finished(isSuccessed,result, codeType, errorMessage);
    }];
}

#pragma mark - 注册界面 校验密码是否有效
- (void)requestPasswordIsVaild:(NSString *)password Finished:(SEGNetworkReponse)finished {
    NSString *encryPassword = [SEGEncryptRule encryptByRsaWithString:password];
    NSDictionary* pramas = @{
                             @"body" : encryPassword
                             };
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/authc-restapi/security/validPwd",nil];
    [SEGHTTPBusinessManager seg_requestJSONWithMethod:POST URLString:urlString parameters:pramas finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        finished(isSuccessed,result, codeType, errorMessage);
    }];
}

#pragma mark -注册界面，根据手机号码、验证码、校验是否有效

//根据手机号码，验证码，校验是否有效
//接口：/v1/userApp/validateCaptchasByTel
- (void)requestValidateCaptchasByTel:(NSString*)tel smsCode:(NSString*)smsCode password:(NSString*)password Finished:(SEGNetworkReponse)finished
{
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    if (tel) [params setValue:tel forKey:@"tel"];
    if (smsCode) [params setValue:smsCode forKey:@"smsCode"];
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/uhomecp-sso/v1/userApp/validateCaptchasByTel",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:params finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        finished(isSuccessed,result, codeType, errorMessage);
    }];
}

#pragma mark - 注册界面，根据手机号、小区、密码注册小区

//根据手机号、小区、密码注册小区
//接口：/v1/userApp/register
- (void)requestUserAppRegisterByTel:(NSString*)tel
                            smsCode:(NSString*)smsCode
                           password:(NSString*)password
                        communityId:(NSString*)communityId
                        randomToken:(NSString*)randomToken
                           Finished:(SEGNetworkReponse)finished
{
    NSString *encryPassword = [SEGEncryptRule encryptByRsaWithString:ValueToString(password)];
    NSDictionary* params = @{
                             @"communityId" : ValueToString(communityId),
                             @"tel" : ValueToString(tel),
                             @"smsCode" : ValueToString(smsCode),
                             @"password" : encryPassword,
                             @"randomToken":ValueToString(randomToken)
                             };
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/uhomecp-sso/v2/userApp/register",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:params finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        finished(isSuccessed,result, codeType, errorMessage);
    }];
}

#pragma mark - 查询小区界面，根据小区名查询小区是否存在

//查询小区
//接口：/v1/community/findCommunityByName
- (void)requestFindCommunityByName:(NSString*)communityName cityCode:(NSString *)cityCode Finished:(SEGNetworkReponse)finished {
    NSMutableDictionary *params = [@{} mutableCopy];
    if (communityName && communityName.length > 0) [params setObject:communityName forKey:@"communityName"];
    NSString *urlString;
    if (cityCode && cityCode.length > 0) [params setObject:cityCode forKey:@"cityCode"];
    urlString = [SEGServerManager serverUrlJoint:kClientRootURL, @"/uhomecp-sso/v1/community/findCommunityByName", nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:params finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        if (!isSuccessed) {
            finished(NO,result, codeType, errorMessage);
            return;
        }

        NSArray *dictData = [result valueForKey:@"data"];
        //        if (dictData.count == 0) {
        //
        //            SEGSearchCommunityModel* _model = [[SEGSearchCommunityModel alloc] init];
        //            _model.communityName = @"对不起，没有该小区";
        //            self.dataSourceCommunity = @[ _model ];
        //            finished(YES,result, codeType, @"");
        //            return;
        //        }
        NSMutableArray *arrM = [NSMutableArray array];
        for (NSDictionary* dic in dictData) {
            SEGSearchCommunityModel *_model = [SEGSearchCommunityModel initWithDictionary:dic];
            [arrM addObject:_model];
        }
        self.dataSourceCommunity = arrM;
        finished(YES,result, codeType, errorMessage);
    }];
}

//忘记密码,找回密码
//接口：/v1/userApp/restPwd
- (void)requestUserAppRestPwdByTel:(NSString*)tel
                           smsCode:(NSString*)smsCode
                       randomToken:(NSString*)randomToken
                          password:(NSString*)password
                          Finished:(SEGNetworkReponse)finished
{
    
    NSDictionary* params = @{
                             @"tel" : tel,
                             @"smsCode" : smsCode,
                             @"randomToken" : randomToken,
                             @"password" : [SEGEncryptRule encryptByRsaWithString:password ?: @""]
                             };
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/uhomecp-sso/v2/userApp/restPwd",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:params finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        finished(isSuccessed,result, codeType, errorMessage);
    }];
}

//app前端修改密码
- (void)requestUserInfoUpdatePwdByTel:(NSString*)tel newPwd:(NSString*)newPwd oldPwd:(NSString*)oldPwd imgCode:(NSString *)imgCode randomToken:(NSString *)randomToken finished:(SEGNetworkReponse)finished
{
    NSString *encryFreshPassword = [SEGEncryptRule encryptByRsaWithString:newPwd];
    NSString *encryOldPassword = [SEGEncryptRule encryptByRsaWithString:oldPwd];
    
    NSMutableDictionary* params = [@{
                                     @"tel" : tel,
                                     @"newPwd" : encryFreshPassword,
                                     @"oldPwd" : encryOldPassword,
                                     @"imgCode" : imgCode ?: @"",
                                     @"randomToken" : randomToken ?: @""
                                     } mutableCopy];
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/authc-restapi/v1/user/auth/updatePwdV2",nil];
    [SEGHTTPBusinessManager seg_requestJSONWithMethod:POST URLString:urlString parameters:params finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        finished(isSuccessed,result, codeType, errorMessage);
    }];
}

// 切换小区入口网络请求

- (void)requestFindMyCommunityFinished:(SEGNetworkReponse)finished
{
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/uhomecp-sso/v1/community/findMyCommunity",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:nil finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        if (!isSuccessed) {
            finished(NO,result, codeType, errorMessage);
            return;
        }
        
        NSArray* dictData = [result valueForKey:@"data"];
        NSMutableArray* arrM = [NSMutableArray array];
        
        for (NSDictionary* dic in dictData) {
            SEGChangeCommunityModel* _model = [SEGChangeCommunityModel yy_modelWithDictionary:dic];
            if (![_model.communityId isEqualToString:kAccountCommunityID]) {//不添加当前小区到数据源，界面上不显示
                [arrM addObject:_model];
            }
        }
        
        self.dataSourceCommunityList = [arrM copy];
        finished(YES,result, codeType, errorMessage);
    }];
}

- (void)requestswitchCommunityBycommunityId:(NSString*)communityId Finished:(SEGNetworkReponse)finished
{
    NSDictionary* pamas = @{
                            @"communityId" : communityId
                            };
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/uhomecp-sso/v1/community/switchCommunity",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:pamas finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        finished(isSuccessed,result, codeType, errorMessage);
        
    }];
}

- (void)requestDeleteCommunityBycommunityId:(NSString*)communityId Finished:(SEGNetworkReponse)finished
{
    NSDictionary* pamas = @{
                            @"communityId" : communityId
                            };
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/uhomecp-sso/v1/community/deleteCommunity",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:pamas finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        finished(isSuccessed,result, codeType, errorMessage);
    }];
}

- (void)requestSaveRegisterCommunityBycommunityId:(NSString*)communityId Finished:(SEGNetworkReponse)finished
{
    NSDictionary* pamas = @{
                            @"communityId" : communityId
                            };
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/uhomecp-sso/v1/community/saveRegisterCommunity",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:pamas finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        finished(isSuccessed,result, codeType, errorMessage);
    }];
}

#pragma mark - 获取语音验证码
/**
 *  获取语音验证码
 *
 *  @param tel      手机号
 *  @param operType 类型 注册：register 忘记密码：forgetPwd
 *  @param finished 完成回调
 */
- (void)requestGetSoundCodeByTel:(NSString*)tel
                         imgCode:(NSString*)imgCode
                     randomToken:(NSString*)randomToken
                            Type:(NSString*)operType
                        Finished:(SEGNetworkReponse)finished
{
    
    NSDictionary* pramas = @{
                             @"tel" : tel,
                             @"operType" : operType,
                             @"imgCode" : imgCode,
                             @"randomToken" : randomToken
                             };
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/uhomecp-sso/v1/userApp/voiceSMS",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:pramas finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        finished(isSuccessed,result, codeType, errorMessage);
    }];
}

/**
 * 变更手机号 -- 用于更换新手机号页面信息填写完成功能
 * @author helen
 * @param oldTel  旧的手机号
 * @param newTel  新的手机号
 * @param smsCode 手机号验证码
 * @return finished 完成回调
 */
-(void)requestChangeTelByOldTel:(NSString *)oldTel
                         newTel:(NSString *)newTel
                        smsCode:(NSString *)smsCode
                       Finished:(SEGNetworkReponse)finished{
    
    NSDictionary* params = @{
                             @"oldTel" : oldTel,
                             @"newTel" : newTel,
                             @"smsCode" : smsCode,
                             };
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/uhomecp-sso/v1/userApp/changeTelByOldTel",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:params finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        finished(isSuccessed,result, codeType, errorMessage);
    }];
}

//获取积分
-(void)requestgetCompleteInformationFinished:(SEGNetworkReponse)finished{
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/bms-api/message/getCompleteInformation",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:nil finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        if (!isSuccessed) {
            finished(NO,result, codeType, errorMessage);
            return;
        }
        
        if ([result valueForKey:@"data"] &&
            [[result valueForKey:@"data"] isKindOfClass:[NSDictionary class]]) {
            self.seg_segcompleteinfomodel = [SEGCompleteInfoModel initWithDictionary:[result valueForKey:@"data"]];
            finished(YES,result, codeType, errorMessage);
            return;
        }
        
        finished(isSuccessed,result, codeType, errorMessage);
        
    }];
}



/**
 * 获取同城热门社区 4.3.7新增
 * @author Wendy
 * @param cityCode  城市编码
 * @param finished  回调
 */
-(void)requestQueryCommunityListWithCityCode:(NSString *)cityCode
                                    finished:(SEGNetworkReponse)finished
{
    if (!cityCode) {
        return;
    }
    NSDictionary *param = @{@"code":cityCode};
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/bms-api/city/queryCommunityList",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:param finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        if (!isSuccessed) {
            finished(NO,result, codeType, errorMessage);
            return;
        }
        
        
        NSDictionary* dictData = [result valueForKey:@"data"];
        if (!dictData || ![dictData isKindOfClass:[NSDictionary class]]) {
            finished(NO,result, codeType, errorMessage);
            return;
        }
        
        NSArray *communityList = [dictData valueForKey:@"communityList"];
        if (!communityList || ![communityList isKindOfClass:[NSArray class]]) {
            finished(NO,result, codeType, errorMessage);
            return;
        }
        
        NSMutableArray* arrM = [NSMutableArray array];
        for (NSDictionary* dic in communityList) {
            SEGChangeCommunityModel* _model = [SEGChangeCommunityModel yy_modelWithDictionary:dic];
            [arrM addObject:_model];
        }
        
        self.hotCommunityList = [arrM copy];
        finished(YES,result, codeType, errorMessage);
        
    }];
}

/**
 * 获取城市列表接口 4.3.7新增
 * @author Wendy
 */
-(void)requestQueryCityListWithCity:(SEGNetworkReponse)finished
{
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/bms-api/city/queryCityList",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:nil finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        if (!isSuccessed) {
            finished(NO,result, codeType, errorMessage);
            return;
        }
        
        NSDictionary* dictData = [result valueForKey:@"data"];
        if (!dictData || ![dictData isKindOfClass:[NSDictionary class]]) {
            finished(NO,result, codeType, errorMessage);
            return;
        }
        
        NSArray *cityList = [dictData valueForKey:@"cityList"];
        if (!cityList || ![cityList isKindOfClass:[NSArray class]]) {
            finished(NO,result, codeType, errorMessage);
            return;
        }
        
        NSMutableArray* arrM = [NSMutableArray array];
        
        for (NSDictionary* dic in cityList) {
            SEGCityListModel* _model = [SEGCityListModel yy_modelWithDictionary:dic];
            [arrM addObject:_model];
        }
        
        self.cityList = [arrM copy];
        finished(YES,result, codeType, errorMessage);
        
    }];
}


#pragma mark - 手机验证码登录
/**
 * 获取登录手机验证码
 * @author Wendy
 * @param tel  手机号
 * @param organId  组织机构ID
 * @param imgCode  图片验证码
 * @param randomToken  唯一标志
 * @param accountCode  账户编码
 * @param businessCode  账户编码
 * @param finished 完成回调
 */
-(void)requestGetLoginSmsByTel:(NSString *)tel
                       organId:(NSString *)organId
                       imgCode:(NSString *)imgCode
                   randomToken:(NSString *)randomToken
                   accountCode:(NSString *)accountCode
                  businessCode:(NSString *)businessCode
                      finished:(SEGNetworkReponse)finished
{
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/authc-restapi/v1/auth/code/sendLoginSms",nil];
    
    NSDictionary* params = @{
                             @"tel" : ValueToString(tel),
                             //                             @"organId" : ValueToString(organId),
                             @"imgCode" : ValueToString(imgCode),
                             @"randomToken" : ValueToString(randomToken),
                             @"accountCode" : ValueToString(accountCode),
                             @"businessCode":ValueToString(businessCode)
                             };
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:params finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        if (!isSuccessed) {
            finished(NO,result, codeType, errorMessage);
            return;
        }
        
        if ([result valueForKey:@"data"] && [[result valueForKey:@"data"] isKindOfClass:[NSDictionary class]]) {
            self.seg_segtelcaptchasbyregistermodel = [SEGTelCaptchasByRegisterModel yy_modelWithJSON:[result valueForKey:@"data"]];
        }
        finished(isSuccessed,result, codeType, errorMessage);
    }];
}

#pragma mark - 注销账号
/// 注销账号
/// @param tel 手机号
/// @param smsCode 短信验证码
/// @param businessCode 短信业务编码
/// @param finished 回调
- (void)requestLogoutAccountWithTel:(NSString *)tel
                            smsCode:(NSString *)smsCode
                       businessCode:(NSString *)businessCode
                           finished:(SEGNetworkReponse)finished {
    NSDictionary* params = @{
                             @"tel" : tel,
                             @"smsCode" : smsCode,
                             @"businessCode" : businessCode
                             };
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/uhomecp-sso/v2/userApp/addUserLogOff",nil];
    [SEGHTTPBusinessManager seg_requestJSONWithMethod:POST URLString:urlString parameters:params finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        finished(isSuccessed, result, codeType, errorMessage);
    }];
}

#pragma mark ----------------------- getter
- (NSArray<SEGChangeCommunityModel*>*)dataSourceCommunityList
{
    if (!_dataSourceCommunityList) {
        _dataSourceCommunityList = [[NSArray alloc] init];
    }
    return _dataSourceCommunityList;
}

- (NSArray<SEGSearchCommunityModel*>*)dataSourceCommunity
{
    if (!_dataSourceCommunity) {
        _dataSourceCommunity = [[NSArray alloc] init];
    }
    return _dataSourceCommunity;
}

- (SEGTelCaptchasByRegisterModel*)seg_segtelcaptchasbyregistermodel
{
    if (!_seg_segtelcaptchasbyregistermodel) {
        _seg_segtelcaptchasbyregistermodel = [[SEGTelCaptchasByRegisterModel alloc] init];
    }
    return _seg_segtelcaptchasbyregistermodel;
}

- (SEGCompleteInfoModel*)seg_segcompleteinfomodel
{
    if (!_seg_segcompleteinfomodel) {
        _seg_segcompleteinfomodel = [[SEGCompleteInfoModel alloc] init];
    }
    return _seg_segcompleteinfomodel;
}

- (NSArray<SEGChangeCommunityModel *> *)hotCommunityList
{
    if (!_hotCommunityList) {
        _hotCommunityList = [NSArray array];
    }
    return _hotCommunityList;
}
@end
